<template>
  <div>
    <div class="flex-col page">
      <div class="justify-between header">
        <span class="text">CURRICULUM</span>
      </div>
      <div class="flex-col group">
        <div
          class="top-group flex-col"
          v-for="(item, index) in datalist"
          :key="index"
          :id="index"
        >
          <div class="section_1 justify-between view_1">
            <span
              class="text_1"
              :style="{ color: item.bolen ? 'rgb(0,255,255)' : 'black' }"
              >{{ item.title }}</span
            >
            <img
              :src="item.bolen ? icon.i1 : icon.i2"
              class="image_2 image_3"
            />
          </div>
          <div class="flex-col section_2">
            <div class="text-wrapper flex-col items-center">
              <span>23</span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      datalist: [
        {
          bolen: true,
          title: "魔力健身操",
        },
        {
          bolen: false,
          title: "魔法少女操",
        },
        {
          bolen: false,
          title: "天天扭呀扭",
        },
        {
          bolen: false,
          title: "巴啦啦小魔仙",
        },
      ],
      icon: {
        i1: require("../assets/img/arrow-a.png"),
        i2: require("../assets/img/arrow.png"),
      },
      show: false,
    };
  },
  mounted() {
    document.addEventListener("keydown", this.showPopup);
    this.$store.commit('com', 'curriculum')
  },
  methods: {
    showPopup(e) {
      var key = window.event ? e.keyCode : e.which;
      if (this.show == true) {
        switch (key) {
        }
      } else {
        switch (key) {
          case 9:
            this.show = true;
            break;
          case 13:
            this.$store.commit('add', this.$store.state.now_page)
            for (let i = 0; i < this.datalist.length; i++) {
              if (this.datalist[i].bolen == true) {
                this.$router.push({
                  name: "curriculum_detail",
                });
              }
            }
            break;
          case 37:
            for (let i = 0; i < this.datalist.length; i++) {
              if (this.datalist[i].bolen == true) {
                if (i != 0) {
                  this.datalist[i].bolen = false;
                  this.datalist[i - 1].bolen = true;
                  if (i == 1) {
                    location.hash = "#top";
                  } else {
                    var str = "#" + (i - 1);
                    location.hash = str;
                  }
                } else {
                  alert("已经是第一个");
                }
                break;
              }
            }
            break;
          case 38:
            for (let i = 0; i < this.datalist.length; i++) {
              if (this.datalist[i].bolen == true) {
                if (i != 0) {
                  this.datalist[i].bolen = false;
                  this.datalist[i - 1].bolen = true;
                  if (i == 1) {
                    location.hash = "#top";
                  } else {
                    var str = "#" + (i - 1);
                    location.hash = str;
                  }
                } else {
                  alert("已经是第一个");
                }
                break;
              }
            }
            break;
          case 39:
            for (let i = 0; i < this.datalist.length; i++) {
              if (this.datalist[i].bolen == true) {
                if (i != this.datalist.length - 1) {
                  this.datalist[i].bolen = false;
                  this.datalist[i + 1].bolen = true;
                  var str = "#" + (i + 1);
                  location.hash = str;
                } else {
                  alert("已经是最后一个");
                }
                break;
              }
            }
            break;
          case 40:
            for (let i = 0; i < this.datalist.length; i++) {
              if (this.datalist[i].bolen == true) {
                if (i != this.datalist.length - 1) {
                  this.datalist[i].bolen = false;
                  this.datalist[i + 1].bolen = true;
                  var str = "#" + (i + 1);
                  location.hash = str;
                } else {
                  alert("已经是最后一个");
                }
                break;
              }
            }
            break;
        }
      }
    },
  },
};
</script>

<style scoped>
.top-group {
  padding-top: 3.13rem;
  position: relative;
  margin-bottom: 2rem;
  overflow-x: hidden;
}
.image_2 {
  width: 0.53rem;
  height: 0.75rem;
}
.text-wrapper {
  padding: 1.31rem 0;
  background-image: linear-gradient(
    100deg,
    rgb(222, 255, 201) 0%,
    rgb(163, 248, 255) 100%
  );
  width: 3.13rem;
}
.section_1 {
  margin-left: 1.25rem;
}
.page {
  background-color: rgb(222, 222, 222);
  width: 100%;
  height: 100%;
  overflow-y: auto;
  min-height: 100vh;
}
.header {
  padding: 2.09rem 1.16rem 0.75rem 1.19rem;
  color: rgb(0, 0, 0);
  font-size: 0.63rem;
  font-weight: 700;
  line-height: 0.5rem;
  letter-spacing: 0.25rem;
  white-space: nowrap;
  height: 3.91rem;
}
.group {
  padding: 0.91rem 2.03rem 0;
  flex: 1 1 auto;
  overflow-y: auto;
}
.image {
  margin: 0.19rem 0 0.25rem;
  width: 1.09rem;
  height: 0.63rem;
}
.text {
  align-self: center;
}
.image_1 {
  width: 1.06rem;
  height: 1.06rem;
}
.view_3 {
  margin-top: 1.25rem;
}
.view_6 {
  margin: 1.28rem 0 -6.91rem;
  color: rgb(0, 0, 0);
  font-size: 0.63rem;
  font-weight: 700;
  line-height: 0.47rem;
  letter-spacing: 0.14rem;
  white-space: nowrap;
}
.view_1 {
  padding: 8.69rem 1.59rem 1.19rem;
  color: rgb(0, 0, 0);
  font-size: 0.56rem;
  font-weight: 700;
  line-height: 0.44rem;
  letter-spacing: 0.12rem;
  white-space: nowrap;
  background-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0px 1.56rem 1.56rem rgba(0, 0, 0, 0.15);
  position: relative;
}
.section_2 {
  padding-bottom: 7.5rem;
  color: rgb(0, 0, 0);
  font-size: 0.63rem;
  font-weight: 700;
  line-height: 0.5rem;
  letter-spacing: 0.14rem;
  white-space: nowrap;
  filter: drop-shadow(0px 1.56rem 1.56rem rgba(0, 0, 0, 0.15));
  background-image: url("https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/622f14ff5a7e3f031097a4ba/622f1ab14fa9330011966385/16474110189214798563.png");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  position: absolute;
  left: 0;
  right: 1.25rem;
  top: 0;
}
.view_4 {
  padding: 8.69rem 1.56rem 1.19rem;
  color: rgb(0, 0, 0);
  font-size: 0.56rem;
  font-weight: 700;
  line-height: 0.41rem;
  letter-spacing: 0.12rem;
  white-space: nowrap;
  background-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0px 1.56rem 1.56rem rgba(0, 0, 0, 0.15);
  position: relative;
}
.section_3 {
  padding-bottom: 7.5rem;
  color: rgb(0, 0, 0);
  font-size: 0.63rem;
  font-weight: 700;
  line-height: 0.5rem;
  letter-spacing: 0.14rem;
  white-space: nowrap;
  filter: drop-shadow(0px 1.56rem 1.56rem rgba(0, 0, 0, 0.15));
  background-image: url("https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/622f14ff5a7e3f031097a4ba/622f1ab14fa9330011966385/16474110189219617543.png");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  position: absolute;
  left: 0;
  right: 1.25rem;
  top: 0;
}
.view_7 {
  background-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0px 1.56rem 1.56rem rgba(0, 0, 0, 0.15);
  height: 10.63rem;
  position: relative;
}
.section_4 {
  padding-bottom: 7.53rem;
  filter: drop-shadow(0px 1.56rem 1.56rem rgba(0, 0, 0, 0.15));
  background-image: url("https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/622f14ff5a7e3f031097a4ba/622f1ab14fa9330011966385/16474110189144143647.png");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  position: absolute;
  left: 0;
  right: 1.25rem;
  top: 0;
}
.text_1 {
  margin: 0.13rem 0 0.19rem;
}
.image_3 {
  margin-right: 0.094rem;
}
.text_3 {
  margin: 0.13rem 0 0.22rem;
}
.image_4 {
  margin-right: 0.13rem;
}
.text-wrapper_1 {
  padding: 1.34rem 0 1.31rem;
  background-image: linear-gradient(
    100deg,
    rgb(171, 253, 120) 0%,
    rgb(0, 234, 255) 100%,
    rgb(67, 238, 253)
  );
  width: 3.13rem;
}
</style>
